﻿using CinemaBookingWCF1.UserNamespace;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Data.Entity;

namespace CinemaBookingWCF1
{
    public class UserService : IUser
    {

        DataClassesCinemabookingDataContext db = new DataClassesCinemabookingDataContext();

        public User GetUserById(int UserId)
        {
            User _user = new User();

            var queryUserId = from x in db.Users
                                  where x.id == UserId
                                  select x;
            return _user;
        }

        public List<User> GetAllUsers()
        {
            List<User> lstUsers = new List<User>();

            var queryAllUsers = from x in db.Users
                                      select x;

            foreach (User singleUser in lstUsers)
            {
                User _user = new User();
                _user.id = singleUser.id;
                _user.name = singleUser.name;
                _user.password = singleUser.password;
                _user.phonenr = singleUser.phonenr;
                _user.email = singleUser.email;

                lstUsers.Add(_user);
            }
            return lstUsers;
        }


        public void SaveUser(List<User> allUsers)
        {
            
        }



    }
}
